#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;

#define INF 0x3f3f3f3f

#define TRACE(x...) 
#define PRINT(x...) TRACE(printf(x))

#define rep(i,n) for (int i=0; i<n; i++)

typedef struct point {
	double x,y;
} Pt;

int _42;
int n;
Pt coords[110];
pair<double, pair<int, int> > graph[10010];

int pai[110];
int rank[110];
int ar;

int retpai(int a) {
	if (pai[a]!=a) pai[a] = retpai(pai[a]);
	return pai[a];
}

bool uniofind(int a, int b) {
	a=retpai(a);
	b=retpai(b);

	if (a==b) return false;

	if (rank[a]>=rank[b]) {
		pai[b]=a;
		if (rank[a]==rank[b]) rank[a]++;
	}
	else pai[a]=b;
	return true;
}

double sum=0.0;

int main() {
	scanf("%d", &_42);

	while (_42--) {
		scanf("%d", &n);

		rep(i,n) scanf("%lf %lf", &coords[i].x, &coords[i].y);
	
		ar=0;
	
		rep(i,n) {
			rep(j,n) {
				if (i==j) continue;
				else {
					graph[ar].first = (coords[i].x-coords[j].x)*(coords[i].x-coords[j].x) +
						(coords[i].y-coords[j].y)*(coords[i].y-coords[j].y);
					graph[ar].second = make_pair(i,j);

					PRINT("%lf %d %d\n", graph[ar].first, graph[ar].second.first, graph[ar].second.second);
				}

				ar++;
			}
		}
		
		rep(i,n) pai[i]=i;
		rep(i,n) rank[i]=0;	
		
		sort(graph, graph+ar);
		sum=0.0;

		for (int i=0; i<ar; i++) {
			if (uniofind(graph[i].second.first, graph[i].second.second)) sum+= sqrt(graph[i].first);
		}

		printf("%.2lf\n", sum);

		if (_42) printf("\n");
	}

	return 0;
}
